Fix IllegalStateExceptions