Implement flexible target specification

See commit message.
No, see my most recent comment on the PR (ie, still todo)