Minor nit:  Constants are used for position, like `BEFORE`, but not for direction.  Consider adding something like `FORWARD` and `BACKWARD`.