Additional JavaDoc and comment cleanup. Make string comparision locale
independend and factor out safeClose().