Further refactoring: moved some dependencies from galry to qtools.