initial version... most of the research code removed to simplify release code