Improved graph mouse control code, and fixed some bugs.