Fixing database lock exception crash, nullpointerexception. Fixing issue #11 and issue #12