Did some changes to some algorithms and some other stuffs