Removed usages of deprecated context functions
Merge changes from upstream master (conflicts resolved)