Just a submission to have all code together, before I make modifications
based on Doina's and Prakash's suggestions.