Adding some debugging, and fixing some issues.