Backend updates

Backend structure rebuild and fixed all tools to work with the url
rewrite nonsense.

Also updated core/db.class.php to use a new, more efficient way of
working.

Also fixed core/form.class.php select case.

Cleaned up a bunch of files.