Add option to grab mouse
Various code cleanup / minor bug fixes