Optimized functionality for taking derby Dump

Still some more clean ups required along with some TEST cases.