Should this part also go into the if body? Otherwise there is no point checking whether t is an instance of TSocket earlier. Other than that, this looks good!