added 32-bit support and writing of multiples (both untested)