Fixed seg fault, may have caused a bug. Kyle will want to look at this.