Cleanup and refactoring create output schema