Bug fixes, improved numerical accuracy

See changelog.