in train changes: added database handling and category activity (not yet
tested)