Second code refactoring and bug fixes