First devicemanager code

There's a lot left to be improved and fixed, but it's a (working)
starting