Added more debug, fixed a bug