Added improved mouse handling