Refactored image upload into its own function. Unified return types.