ID set to null when AR is deleted + small performance improvements and refactoring.