Minor refactor and fix