More work on database (added switches). Improved notification and socket connection workflow.