Restructured main to prepare for client/server integration.