various improvements and simplifications