Deleting a machine from IM does not delete the machine from DB. You will need to run a DELETE against cm_computer_system table and that should delete corresponding entries in all cm* tables.
Unforuntately, QoS tables are not dynamic. Please try the SQL scripts attached.