First rough version

There's still a lot missing but the basics work.