Logging and minor fixes