Fixed memory leaks, and added a correct method for CNAME diversion