Finished random pattern generation and improved collision detection.