Initial version based on Divmod.Class from Nevow