Windows sporadic coordinates overflow fixed plus small refactoring.