Fix several issues pointed out by spec failures.