Fixed some algorithms