Implement flexible target specification

See commit message.
This seems to have lost the fall-through case?