Fixed small issues, added logging, added catch all exceptions