Folded main's globals to local scope