Many bug fixes and additions.