Removing heavy metals or compounds thereof