Various minor bug fixes and debugging implementations.