Better test code; cleanup of the heap itself; documentation