Some edits preparing the main loop.