Refactor a bit and fix the disappearing menu.