major bug fixes in division procedure