Clean unnecessary code, add direction threshold as a variable

Cleaning parts of the code that are not needed + adding a "direction threshold" as a variable.