Warious fixes, overhauled mode setting.