Implement flexible target specification

See commit message.
Just a reminder to handle this better