Refactor game scoring logic to better check for error cases.