At last! Solved problem 50, with a memory bug in the free part though