Integrated the edit layout and fixed some issues with the database code