Added "exit" option. added comments and cleaned up editing code