one more round of fixes and cleanup