forked from savanah, add some fix.