Fix for IllegalStateException on some devices