Check for missing filenames in ThreadLocalContext
Fix bug where ThreadLocalContext is created without filenames
Add missing assignment to sqs
Add double-check to avoid recreating contexts