Fixed ClassCastException and added the possibility to define the database.