Slight changes to index.php so ajax requests works better
Added (]}' to json returned data, for security reasons
Updated so that data posted to the script will have it's columns renamed prior to being sent to the database

The reason for this is that since we rename the columns before they
are sent to the browser, we should reverse the naming when we get
data sent to us. Otherwise the mappings will be all wrong and there
is a risk data will either not be saved or perhaps even corrupted.

Also, cleaned and reformated code in the file...