general cleanup and tweaking