Revamped exception listener and added finish middleware