- Detect null pointers in trade-related functions - Fix typo/issues pointed out by @dscorbett - Reorder includes