Cleaned up context creation a little; now prints out error codes.