Code cleanup, major rewrite of Ball