Initial commit. Lots to fix up. Basic idea is there.