fix some bugs & disambiguate some code.