First commit at quite working prototype, not tested in real life though