Remove edge effects due to nan starts and ends

Fixes #9