Minor touchups

Generalized out a few functions.

Let me know if you have any comments or things you'd like changed.