Fixed some errors and bad programming