Aded better support for multiple modes.