Move length calculation from before_save callback to the one-time import