Added log messages
Minor improvements and changes
Major refactoring