Handle resolution scopes

@titanous 
Updated to reduce nesting