Added functionality for changing modes.