Performance improvements

several hotspot optimizations for memory + cpu consumption
Ah, very good :)