Final refactor, rev. 2