Added more Debug information and error checking