Add debug build option and fix some warnings