Major improvements on attachments logic (class, bbcode, layouts)