Fixing a few small bugs in security and common infrastructure