Added more validity and dirty block invalidation logic. Passes every existing testcases