simplified three logic and made it more standard
added trackball support