refactoring; code style fixes