More code style and refactoring