First commit

First code commit. Incomplete but works fine for hasData=T.