Fixing some issues in scope apply