Transaction refactoring and code cleanups; no functional changes