Implementing some things necessary for `trim`.