Avoid warnings due to unitialisation of attachments property, and incorrect login in get_attachments()
Various whitespace fixes