Fix issues in order to make it compile and not crash