mouse control + minor code improvements