Moved main() entry point to top of file