Refactor and clean cart

* This patch includes a long overdue cleanup of the codebase
  carried over with minimal updates from version 2.4
* Splits complex functionality into simpler methods
* Made the login signal handler to a static method of the model