fixed #185 by integrating the pull request and fixing the NPE occuring in the local mode