Added collision checking (doesn't work completely).