Made a few minor changes and setup for main loop implementation.