Added several type casts due to no portable way of doing printf of