BUG: Memory fixes