Clean and correct the code and rename a function

That's all I did - I swear!