Adjusted code for desktop handling.