Fix autotools errors.
Fix int problem in 64bit environment.
Fix compatibility problem.