Fix some bugs in order to run in the big data

@JavierJia @jakebiesinger @Elmira88 @Nan-Zhang 

When we try to run in the big data, there are some bugs. This PR fixed them. Have a look!