Prefer lists:flatmap to lists:foldl

The only change introduced by this commit is that the options shall
now be in the reverse order, but based on a quick reading the code
accesses the options by key using proplists:get_value - that
accidentally means that in case of multiple entries with the same key
the first value from the list is picked.  Enforce that only one such
option is present using proplists:get_all_values.