Changed double quotes to single quotes where not required.
Tidied up some indentation.
A little more tidying and consistency.
A few more nips and tucks on main code.
The same general tidying of lib/*