Multiple fixes to err handling, logging and others