Rough take on refactoring into stand-alone lib...