Fixed some warnings, like sprintf %i warnings (converted to %lu), fals vs NULL, etc