Move plugin callbacks to types.h
Reformat code