Refactor and code styles