Fixed NPE when deleting a portfolio

Issue: #162