Fixed some bugs and added more prints while DEBUG is True.