As far as going back to generator mode it would seem if you applied power between the diode and moter it would generate as soon as your relay opened Or maybe use a double throw relay the normally closed contacts for batt charging