initial check-in
this is a working version although it still needs some love in some places