Fixed database fetching and added a bunch of nice event handling.