Clean up source generation to try to make it more robust.