Code refactoring and reformating