remove dead code
extract model code into standalone lib classes and modules