Fix window edge and broken motion detection, closes #3