Refactored and a bug fix cart-related.