Database code and structure clean-up