separated state functions out of main
added directory dep
moved state to own module, tightened imports