some renames and optimizations in code