crossplatform fixed

Fixed some bugs and issues with 64-bit plaftorms and modern gcc.