Fix various warnings

Fixes for warnings reported by Eclipse and Findbugs.