Fixed memory problem for check.c, still som tests to be introduced.