Moved path splitting into its own function.