added touch event support, discovered bug in calculations.