fixed many size_t format warnings and a type cast