Fixed some bugs in dicomViewer

Cleaned up the code in dicomViewer and fixed some bugs with a few of the
functions so that now they work much better.