Refactor id and class parsing