Various refactoring; re-implement BMM_GENERIC_TYPE.type_substitutions and add new autotest.
pdate documentation