Some fixes (the directive restrict was insanely wrong) and shortening of the functions