Significantly refactored module, to enable future development of the module and simplify use. Is fully compatible with all previous usage.