Centralize definitions to allow for more thorough cleanup on error