Changed class names, made allocation more explicit and added cleanup