Fixed a couple of bugs

Also improved readability in the function checkCollisions.