teapot: Reorder code to be a bit clearer