these are hacks (s/long/int/, etc.), but this code really needs a heavy cleaning (including fixed-size typing) and I don't have time to give it one now.