Fix things flagged by FindBugs, plus compile warnings

    A number of these are switching to use safeEquals()