Modularized collisions code.
Trying to merge with Thinh's changes