minor improvements
Performance improvements and some cosmetic changes