main.h almost merged