HV-373

I still want to add some tests, but I create the pull request anyways for now.