Fix bugs related to name resolutions