Re-factored attachment handling