various improvements and corrections