Fix for the recently reported accounting problem: Ticket #396 and Ticket #202.