Reorganize into a standalone library WIP