A couple of fixes
Returning from blah | foreach doesn't do what I expect