complete misra-gries + other minor fixes