Fix gap calculations #17