Fixed a couple bugs, specifically a null pointer exception.