Added ability to swap between editing and viewing states.