ranges are now 0..max in a leap year and 1..max otherwise

various fixes suggested by @jodastephen