Adding more error checking, narrowed down kernel error