Added a logger for more maintainable and configurable debug messages.

Fixed a bug with context setting so that all children are updated on
context update.