Fixed all the bugs and made some corrections.
Deleted unused code.