Refactoring a few things out for readability.