lots of stuff. Probably final version before adding tests.