Major refactoring of the design hibernate included but still has to be tweaked properly to work