WIP: restructuring into libraries