Generic improvements and bug fixes