main.c cleaned up