Significant refactor. Got mouse movement working correctly.