Added more debug log and possibly fixed the macosx problem