Fix crash on startup and crash on button click