Added debugging code to help identify problems