Fix for Bug Report #119 (SF)

Fixes for Bug Report #199 on SourceForge. Also includes jUnit test
cases.
Fixes for SF Bug Report #119. Also has jUnit test cases.