General improvements and bug fixes.