various cleanup and fixes