Restructured to add mysql db support