Replaced deprecated by new api. 

Cleaned up ModalProvider so no dangling references are around.