Complete refactor with passing unit tests (except one removed as of now)
Uses naked pointers and unique_ptrs intelligently.