Adding Irfan's database code; Fixed application exit issues; removed unused files