Super cleanup ball's code + correct some bugs.