performance enhancements

and bug fixes