Minor bugfix and improvement