improvements and bug-fixes