Fixing warnings about invalid type conversions