How sleep habits can cause headaches