Fix bugs in previous two commits.