Fix build errors in debug mode
Fix runtime errors in debug mode