Some code refactoring, comment fixing and removal of unused imports.