Revert "Fix memleak (should fix #1081)"