Modified when.js to avoid deferring callbacks using setTimeout (this breaks IndexedDB). Added promise-based API wrapper for IndexedDB.