TODO: Finish documentation, revise contracts (again), cosmetics.