Improvements to main.c