first pass at object restructure and individual psql funcs