cleaned up some, and added setmode check against same mode