Knight: fix memory leaks.