Bug fixing - making two variables global again
Removing unnecessary log messages
Changes to comments, formatting changes and removing redundant statements