Factor out setting max_size in to its own function