Complete edit script rewrite

Less buggy, must find the bug on MySQL writing -
Its not updating the queries