Refactoring code in the musicpackage