fixed api descrepencies, and some bugs