cleanup code
correct prototypes
move check macros to target...h files