Updated modal handling and back button fix for mobile