Fixed refactoring issues