Add warning and error macros, asserts, and checks. Convert internal uses of C assert() into ours.