Refactor types.h & cleanups