Preliminary working version.  Very buggy