style improvements, optimizations in code wrapper