Big revamp to improve robustness, using xamel to parse content tree