refactor out types.hpp and output.hpp