Cleaned up some collision detection code