Lots of work on the refactored version