reorder and cleanups