Worked out errors. Random segfaults