Cleanup & redoing database code