Almost done with refactoring
A couple remaining things to add