Fix gap handling