Implement flexible target specification

See commit message.
Is this being used? Am I missing something?