various fixes to improve performance