Added debugging code to dimension checking