I could refactor some more, but I'm going to call it done :)