Major update to work with MATLAB R2014b's new figure handling mechanism.