Restructured modes and added a test.