Partial work
Further refactoring / 3D work. Tests passing.