Remove some unused vars, shadowed struct and sanitize printf format strings.