Moved some common codes to destroy() method.