Fixing #290 and some failing unit tests.