Refactor some stuff and add specs
Add some plumbing