portfolio now has its own function in the model, and some other bug fixes