fix bugs in dirty-write, clean dead code, add revision Id extraction code