Finalize refactoring

Finalizing refactoring, verified tests passing in Windows and Ubuntu.