Fix memory leaks

Now here as requested at https://github.com/LMMS/lmms/pull/1469