Template for handling invest, invest_error, divest_error and balance events; other miinor changes.