This work is now useless, as @yirkha did it better. So I'll just keep this dirty prototype for my own history