Fixed some code errors