fixed compile errors
Fixed seg fault