refactored to reduce amount of state
Better unpacking of arguments when running a procedure set, smarter caching, added database connecters where needed.