Fixed some issues with previous refactoring