general cleanup/optimizations/fixes