Revert "All library stuff, quite big actually"

This reverts commit 95e4d3bf6462e59a928a121e63f4e077f87aba2d.
Revert "Revert "All library stuff, quite big actually""

This reverts commit 0b37e47c61fdf1ae7f3df7ab1df167b886bec30d.