Some pretty significant refactoring to better organize the code.