Finished fixing errors, still looking for a memory leak