Split out a lot of transaction functions in hopes that logic can be reused; fixes #3 by no longer creating databases once they are referenced