Fixing refactor crashes