Refactor port & robot to pure JS style