Corrected refactoring bugs