Fixing issue #330 and some failing unit tests.