add 0d exception and fix memory bug