small optimizations
small modifications
removed temporary allocations/frees