Several changes, basis for discussion

*WARNING*: this pull request is not meant to be merged as is!
It is rather meant as a basis for discussion and a proof-of-concept of some ideas, but for many things improvements are needed.
Documentation is lacking for most of the new features.

In-between new features, there are also a few minor bugfixes which can be cherry-picked if desired.

Some of the commits became obsolete because of following commits.
e.g. the function `decode_number()` (d72075f) is not needed anymore because the specialized types introduced in d31a484 provide a much better solution to the problem.
With that, most changes from 2833332 became obsolete, too.

If desired, I can provide individual pull requests for certain features (I can also add documentation, where lacking).