Another round of fixes and cleanup