Some bug fixes.
More bug fixes