Fix memory leaks (needs refactoring) and better apertures