Forward port of PR #106 and #141

Support of media and defer attribute are now working on v2.0 as well.