Improved contexts stack implementation
Fixed a bug in code that caused XCode editor crashing