Microoptimizations

Some small microoptimizations to reduce memory usage and increase the performance a little bit.