Bug fixes; minor improvements