Refactoring and code style improving