some failed attempts at plugging memory leak