Fix a bug in which maxKey maynot be long enough to hold the longest key.