Devices

@mstimberg, take a look and maybe do an initial merge if you think it's OK to go into master? May not play nice with the functions branch.