Refactor and cleanup #2