Complete database system. Refactoring frontend-back end interaction.

Fixed error in logout