Fix errors thrown on page load