Index: Makefile
===================================================================
--- Makefile	(revision 1164)
+++ Makefile	(working copy)
@@ -12,4 +12,7 @@ clean-cache:
 clean-hphp:
 	rm -rf hphp/build/*
 
-clean: clean-cache clean-hphp
+clean-sessions:
+	find /var/infoarena/sessions/ -name sess_\* -exec rm {} +
+
+clean: clean-cache clean-hphp clean-sessions
Index: common/attachment.php
===================================================================
--- common/attachment.php	(revision 1164)
+++ common/attachment.php	(working copy)
@@ -186,9 +186,13 @@ function image_resize($image_info, $filepath, $new_image_info,
                     $image_height);
 
             if ($new_filepath != null) {
-                return imagegif($image_resized, $new_filepath);
+                $ret = imagegif($image_resized, $new_filepath);
+            } else {
+                $ret = imagegif($image_resized);
             }
-            return imagegif($image_resized);
+            imagedestroy($image);
+            imagedestroy($image_resized);
+            return $ret;
 
         case IMAGETYPE_JPEG:
             $image = imagecreatefromjpeg($filepath);
@@ -199,9 +203,13 @@ function image_resize($image_info, $filepath, $new_image_info,
                     $image_height);
 
             if ($new_filepath != null) {
-                return imagejpeg($image_resized, $new_filepath);
+                $ret = imagejpeg($image_resized, $new_filepath);
+            } else {
+                $ret = imagejpeg($image_resized);
             }
-            return imagejpeg($image_resized);
+            imagedestroy($image);
+            imagedestroy($image_resized);
+            return $ret;
 
         case IMAGETYPE_PNG:
             $image = imagecreatefrompng($filepath);
@@ -218,10 +226,15 @@ function image_resize($image_info, $filepath, $new_image_info,
                     $new_image_width, $new_image_height, $image_width,
                     $image_height);
             imagesavealpha($image_resized, true);
+            imagecolordeallocate($image_resized, $col);
             if ($new_filepath != null) {
-                return imagepng($image_resized, $new_filepath);
+                $ret = imagepng($image_resized, $new_filepath);
+            } else {
+                $ret = imagepng($image_resized);
             }
-            return imagepng($image_resized);
+            imagedestroy($image);
+            imagedestroy($image_resized);
+            return $ret;
 
         default:
             // unsupported image type
Index: common/textblock.php
===================================================================
--- common/textblock.php	(revision 1164)
+++ common/textblock.php	(working copy)
@@ -77,6 +77,7 @@ function get_snippet($tb, $max_num_words, $whole_news = false,
 
             $cache_res .= '<a href="' . html_escape($url) .
                 '"> &raquo; Citeste restul insemnarii</a>';
+            $html_dom->__destruct();
             unset($html_dom);
         }
 
Index: hphp/config.hdf.sample
===================================================================
--- hphp/config.hdf.sample	(revision 1164)
+++ hphp/config.hdf.sample	(working copy)
@@ -16,7 +16,8 @@ Log {
 
 Server {
   Port = 8000
-  ThreadCount = 50
+  IP = 127.0.0.1
+  ThreadCount = 30
 
   SourceRoot = --write-me-IA_ROOT_DIR--
   IncludeSearchPaths {
@@ -26,7 +27,7 @@ Server {
   RequestTimeoutSeconds = 30
   RequestMemoryMaxBytes = 67108864
   EnableMemoryManager = true
-  MaxPostSize = 65
+  MaxPostSize = 65                  # = RequestMemoryMaxBytes + 1 in megabytes
 
   FatalErrorMessage = Something went terribly wrong... Check back :)
 
@@ -83,3 +84,9 @@ VirtualHost {
     }
   }
 }
+
+MySQL {
+  ReadTimeout = 4000
+  SlowQueryThreshold = 2000
+  KillOnTimeout = false
+}
Index: scripts/check-attachments
===================================================================
--- scripts/check-attachments	(revision 1164)
+++ scripts/check-attachments	(working copy)
@@ -24,6 +24,7 @@ while ($att = db_next_row($res)) {
         unset($extra_files[$fname]);
     } else {
         $extra_atts[] = $att;
+        continue;
     }
     if (filesize($fname) != $att['size']) {
         $att['file_size'] = filesize($fname);
Index: www/config.php
===================================================================
--- www/config.php	(revision 1164)
+++ www/config.php	(working copy)
@@ -67,7 +67,7 @@ define("IA_SIDEBAR_PAGE", "sidebar-ad");
 define("IA_BLOG_SIDEBAR", "blog-sidebar");
 
 // LaTeX support
-define("IA_LATEX_ENABLE", false);
+define("IA_LATEX_ENABLE", !IA_DEVELOPMENT_MODE);
 
 // List of safe MIME types
 // FIXME: add more?
Index: www/static/css/iconize.css
old mode 100755
new mode 100644
Index: www/views/round_delete.php
old mode 100755
new mode 100644
Index: www/views/task_filter_results.php
===================================================================
--- www/views/task_filter_results.php	(revision 1164)
+++ www/views/task_filter_results.php	(working copy)
@@ -1,8 +1,8 @@
 <?php
-require_once(IA_ROOT_DIR . "www/macros/macro_stars.php");
+require_once(IA_ROOT_DIR . 'www/macros/macro_stars.php');
+require_once(IA_ROOT_DIR . 'www/format/table.php');
 
 include('header.php');
-include('format/table.php');
 
 function format_title($row) {
     $title = "<span style=\"float:left;\">".format_link(url_textblock($row["page_name"]), $row["task_title"])."</span>";
Index: www/views/textblock_copy.php
old mode 100755
new mode 100644
