Reorganize more code