WIP refactoring scanner to stages