Completed database layer re-write and various other changes