Avoid crashes in jinja extensions when attributes are unset
PEP8
Fix template to not error out when editing a threaded message (e.g. a reply)