Code review fixes & refactor