Stuff from Horfius's fork.