Cleanup of main, better memory, goto

I think the base code is roughly as clean as its going to get