Implement flexible target specification

See commit message.
Reminder to handle this better