fixed memory leak (see https://sourceforge.net/tracker/?func=detail&aid=3605235&group_id=55736&atid=478070)