Massive patch to make 'make check' work properly. Many compilation fixes -- everythi...