moved type definitions and function definitions to header files