Fixed and cleaned up insert.php. Also some minor fixes.