some misc improvements and bug fixes