Added extra flexibility to instruction generation. Fixes #142 and fixes #141.