Added the required changes to handle modal re-initialization.