First working version

Probably needs help, but ready to be put to work.