Removed a bug in context setting and some debugging messages