Updated query generators, functions and triggers