Fix infinite loop bugs in prune rect list and place rect functions.