Destructor and other bugs fixed