needs a test suite but putatively fixes some bugs