some cleanup and fixes