Performance optimizations suggested by RehabMan