More refactoring, extract types to .h file