Fixed  p1-p4 ON/OFF switch, and fixed some bugs