Improved logging, minor fixes