improve writer functionality

add new methods for handling updates. write generic methods for creating
queries. improve method abstraction.
bugfix for count oddity
update var names for local scope.
improve naming. add break conditions to compare loop.
add mapping call to handle methods.