flatcap merge: minor tidying
 * drop unnec casts
 * reduce scope
 * tidy logic
 * boolify
 * tweak #include guards
 * add missing mxapi functions
Latest commit 157fd50 Sep 4, 2018