Code adapted for 32-bit support