Improve the portability, i.e. make compile on linux.
Also hopefully reduce type conversion warnings... hopefully.