Refactor some code to be more compact.