cleanup code
correct prototypes
rename some symbols to more suitable names
restructure header files