Code cleanup
Mode set and get functions