Debug code changes for tail plugin

Added debug statements to look at code flow
Did some nan checks to make sure variable is set to 0, before operations are made