Fixed bugs in a few files