Cleanup & comments after Jan's review.
Behavior checkers added.
Trivial inlining.

Trivial inlining code mostly there, refactoring on the go.
The code is not tested or even executed, this is a sync commit only.