Implement flexible target specification

See commit message.
copy/paste bug (may want to check the data layout string as well)