Fixed some issues with recent refactoring