Implemented global context and fixed bug.