Fixed database bugs and changed behaviour of back key.