Fixed CERT MEM04-C; CWE-131, fixed a memory leak in core, adjusted a but to match our style