Restructured some code.