Refactoring portfolio.js

Various changes