Fixed few bugs, including a serious one for non-unique locations