fixing some null reference errors