added clamped subtraction macro, general code cleanup



<!---
@huboard:{"order":184.75,"milestone_order":67.0,"custom_state":""}
-->