clean obsolete code and improve database initialisation