move loader patch logic into its own module