Fixed memory leaks

Fixed memory leaks;
Use debug heap crt to dump leaks;