Adds accumulator and fixes some errors