fix some formatting and casting errors that gcc pointed out.