Bug fixes for debug feature