Mark an memory leak and fix a delete bug