ticket:9 fixes, optimizations