added header files, some c fixes