Fixed and refined the collision system

(excuse the assembly-style names for variables)