Added analysis package and removed some bugs