Preparing for main loop operation