Add TRACE_DIR, remove some safety checks which should be OK, improve TRACE_ENTER/EXIT, fix small bugs, fix allocator