General improvements and debugging.