Menu: Fixed several issues with the mobile menu and optimized the code (fixes #3982, #3983, #3984 and #3986)