Some refactoring getting closer to a usable thing