Fix parsing bug with maps with map and lists as key and value

This pull request makes the parsing of maps much more robust and more inline with the flexibility of the ruby equivalent.

Fixes #509.