Removed redundant J1.5 code
Removed or replaced $query = $db->getQuery(true) with $query->clear() where possible