Adds boiler-plate code (copied from Psi).