Combines !54 (closed) and !49 (closed) and applies minor fixes that are needed before this is deployed