Reorganize some code.