Add ordered dict support for keywords.

Hi @mbernasocchi,

This addresses the issue you picked up. Please have a quick look at the pr.

This addresses the problems raised in #1324.