Refactor scotch and add missing dependencies on flex and bison.