Added corrections for snapping into gaps