Implement flexible target specification

See commit message.
Oh, found it.