Added ResourceManager.commit(), re-engineered the main loop to use it, other associated refactoring.