FindBugs - Boolean comparison: == should be .equals()
#520
fixes based on FindBugs results

should check the type is compatible before casting it
Merge remote-tracking branch 'origin/master'