Various bugfixes and enhancements
FunctionalDependencies and some refactoring