fix database.destroy()
refactor into base.js
refactor into layout and regions