Reorganize some code. (dm)