Splits lib and tool program code

I probably have no idea what I'm doing!
Just don't know how that is normally done!