minor improvements and bug fixes