Added better subdivision algorithm.