Refactoring and some updated comments