Initial code commit - much debugging remains to be done.

Associations are not yet handled correctly.