595 to drive multiple 4051

I'll use analog input pins both with analogread() and digitalRead()

That doesn't make too much sense.

If you want to read a lot of pots then use the arrangement shown in this project of mine:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Footsteps.html
That has 16 analogue inputs. It is easily extended to 40 inputs by using the other analogue input pins with a 4051 on each pin.