sync with phenotips - Mar 13 2014
some refactoring