Cart improvements and some refactoring