Several performance enhancements

This version contains bug fixes and several performance enhancements