Added many changes to mote code.