bugfixes and accuracy improvements