Fix some errors and enabel debug mode