Fixed bugs in creation/removal of capabilities