Fixed memory leak (thanks @docvvf)