Final branch commit, fix demo code, redone the Stat.java code and
optimised it and did minute bug fixes