Minor refactor and code cleanup