cleanup code
fix LONG_MIN and LONG_MAX for platforms with 64-bit long type