Cleaner code, JSLint approved

Cleaned code, bug fixes, JSLint approved.