bugfixes memory leak