main.c cleaned-up