Cleaning up the visualiser code, still needs tested using the device