Remove hardcoded security tokens
Layout improvements for neatness
Remove blank lines and use urlencode() where appropriate
improvements to the code layout and bug fixes