First working version, still lots to be done.