Add generic support to CF build; fixes #327

This PR ports generic support to CF using fixes created by Neil in his Crestron build. Any further problems with this feature should have new issues created so we can work them in priority order.
You probably have a better idea than I do after working on the code. If you think that our current test suites exercise the code well enough to give you confidence, then feel free to merge. Besides, this code will never be executed by the majority of users, so there is little chance of a regression.