Hopefully fixed all memory leaks...