add SQL for db setup, additional code cleanup