Code review changes and refactor