Legal code optimization