#3961: Added context utilization in x64. Refactored some code