Added more logging and minor cleanups