Principles of organization in S layers