fix crash & remove debug code