Configuration, refactor, and tests