Little changes from ckarlof proposal.