collision detection: CS optimizations + unfinished detection code