Updated to run with different modes