Refactored database.js

Removed database namespace, inlined several functions, renamed
lucu.database.open to lucu.openDatabase and replaced its usage at all
call sites.