Lots of copypaste. Need to turn some of this into a module.

Signed-off-by: Ricky Elrod <ricky@elrod.me>