add include guards and move foreach out of main
prepare for base types
fix header files