minor speed gain refactorings, reimplementing collision between rectangles