Rework mouse code for better acceleration

formatting updated