Enhanced logging and minor bug fixes