more cleanup and tests