First cut at trying to better organize code.