Merge in debugging code and bugfixes.