Large bug fix commit.
Add a setting for ws-template.
Replace idio with new PLY-based 'id' implementation. Tests all pass.