Clean up code a bit more; add a class.