#137: merged and restructured
#15: further improvements but still lots of work to do