Some cleanup, corrections to the log messages and removal of possible leaks