Copied Vincent's fixes from other branch