Unbreak tests and a bunch of definitions.

Please remember to add tests and actually check them.