Refactor sparkle functionality into its own file