Restructure some code.