Fix type conversions and inconsistencies.