move class defs into lib, basic work on class functions and some top down design