Simplify this stuff a bit and get rid of the ugly overflow hacks.