A bugfix and some improvements