Overhaul using code from https://github.com/robo-hamburger/remoterie