Fixed some bugs and ambiguity