Minor bugfix and cleanup