This is not totally comprehensive, but at least it's a start for the core functionality. In the next commits, we'll also use this base to add some regression tests.