Fixed bug with null reference exception.