general cleanup and fixes