Flexible Latching: A Biologically-Inspired Mechanism for Improving the Management of Homeostatic Goals