Database refactor

- Added database to threadlocal
- FrontController cleanup
-  Fixed render bug of DataSetViewer when datasetname contains invalid character