Collision-detection and general bug fixing