fixing pointer issues/more segfaults