builds and checks as a package.
optimisation rewritten a bit