Refactored Task class (reduced by 93 lines)