Improve collisions code