here is an updated copy of the galleries/global.php file that should correct the error you are getting.
the problem with the navigation on 3 lines is caused by setting the width, the current navigation needs to have at least 501 pixels in order to show on one line.
edit the ribbon to only show 4 thumbnails to make it fit in the space you have.