complete refactoring of the Spheres program, making it easier for extension