Refactor snowflake.js and demo