Fixing bugs in API