Fixed some errors in the code