fixes, optimizations