fixing mismatch new/delete and making various dtors virtual.