Remove unnecessary casts. Wrap the remaining macros into do while