fix some issues when using new and calling member functions