Rearrange and cleanup functions, share preferences