Working final version of desktop code