Move generic parts from Eyescale/Lunchbox#32 to here