With regard to the program failure when a legend handle is found, I changed the "&&" to "&" on line 60 and changed the "Legend" to "legend" on line 61 and the program properly neglects the legend handle.
There's one Pick of the Week called zoomAdaptiveDateTicks
http://www.mathworks.com/matlabcentral/fileexchange/15342
which is <20 lines and works great.