Improve gui and db interaction