Sound + slight refactoring and fixing.