Added bouncing off walls and some minor refactoring