bug fixes, relating to logging and refactoring