fixed port_num being an instance var, added some more master/slave code