Improve naive division algorithm (patch contributed by Brad Lucier)