Code cleanup, preparation for UI changes in v2