Check that previous and next buttons exist before trying to add classes to them. #281 

In addition, some of the logic of setting the classes for the next, previous, and innerHTML for the skip buttons were reworked to make it more readable and simple.