Implement flexible target specification

See commit message.
What's the difference between this and the preceding section?