Code has been corrected and optimized

Everything is in the commits and the readme