fix some memory leaks and restore compilation under linux