Various bits to get this working.