Unit Detection Improvement

Improved protection against unit indexes being reused.