Make deleting more generic and stop querying the table directly