moved some stuff to lib