Move structure stuff to lib