sv: bugfixes and cleanup.