cleaned up some of the JSHint warnings and updated the finalHandler