fixed a bunch of random refactoring errors