Bug fixes plus minor improvements