restructured lib a bit