Bugfix and improved performance