Refactored achievements handling.