Fixes a number of issues with database connection, discussed in team boards

Signed-off-by: margarett <bruno.m.alves@gmail.com>