Introduce a library, fix another memory leak