Removed memory leak, thanks to diath for spotting it.