Bugfix and cleanup.