Fixed memory leak, thanks to Fredrik