Add more comments and fixed an end game bug.