Fixed random entity memory leak + loops