Working version

This is the first working version. Still a long way to go.