Incorporating changes from https://github.com/robertoles/spree/commit/041b512e67ee5030cf76c2784fd8ee44c93c0d04