Merge "Misc attachment code cleanups"