UPDATE: cleaned code i) made naming more consistent (e.g. data -> x, eot -> mode) ii) replaced . with _ in naming of objects in examples