Fixed a bug and explained a memory leak