Fixed bugs in API