Removed buggy micro-optimization.
Fixed bugs found by dmalloc.
Valgrind friendly machine code