Fixes Issue #2225 & Use models instead of $this->db

Takes care of issue #2225
and use models when appropriet