A few fixes for bug #6.