Fix context error, fix fatal error due to legacy code