Initial commit of working code - about two days work.