Lots of bug fixes
Bug fixes on logging