performance related changes and some NPE fixed
Merge pull request #173 from indikasampath2000/performance

performance related changes and some NPE fixed