[WIP] Refactor toMap

I propose refactoring `toMap` and `toMultimap` to be more Scala idiomatic. Here is my initial idea about `toMap`.

Any thoughts?

/cc @samuelgruetter @headinthebox