diff --git a/software/cloudooo/buildout.hash.cfg b/software/cloudooo/buildout.hash.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..d232e682b0fdb73ebd59aac0a7dec0f0674f7b6d
--- /dev/null
+++ b/software/cloudooo/buildout.hash.cfg
@@ -0,0 +1,22 @@
+# THIS IS NOT A BUILDOUT FILE, despite purposedly using a compatible syntax.
+# The only allowed lines here are (regexes):
+# - "^#" comments, copied verbatim
+# - "^[" section beginings, copied verbatim
+# - lines containing an "=" sign which must fit in the following categorie.
+#   - "^\s*filename\s*=\s*path\s*$" where "path" is relative to this file
+#     But avoid directories, they are not portable.
+#     Copied verbatim.
+#   - "^\s*hashtype\s*=.*" where "hashtype" is one of the values supported
+#     by the re-generation script.
+#     Re-generated.
+# - other lines are copied verbatim
+# Substitution (${...:...}), extension ([buildout] extends = ...) and
+# section inheritance (< = ...) are NOT supported (but you should really
+# not need these here).
+[template-cloudooo]
+filename = instance.cfg.in 
+md5sum = 6e4431cf4b0a0d034402604b1e2844c0
+
+[template-cloudooo-instance]
+filename = instance-cloudooo.cfg.in
+md5sum = afbfed1d762e5cdf7c6fd1292e7b28e7
diff --git a/software/cloudooo/instance-cloudooo.cfg.in b/software/cloudooo/instance-cloudooo.cfg.in
index f7fd01b8d9e2ed8ce0d62b09bd34737eb752e4f5..f9d4953f2a3e15e3c9247fadb2f0f1c5742b9da9 100644
--- a/software/cloudooo/instance-cloudooo.cfg.in
+++ b/software/cloudooo/instance-cloudooo.cfg.in
@@ -10,6 +10,7 @@
 {%   set next_port = slapparameter_dict.get(instance_parameter_dict['port-parameter-name'], next_port) | int -%}
 {% endif -%}
 {% do assert(next_port > 0) -%}
+{% set next_port = itertools.count(next_port).next -%}
 
 {% set backend_count = instance_parameter_dict['backend-count'] | int -%}
 {% if instance_parameter_dict.get('backend-count-parameter-name') -%}
@@ -33,9 +34,8 @@
 {%   set mimetype_entry_addition = mimetype_entry_addition ~ "\n" ~ slapparameter_dict.get(instance_parameter_dict['mimetype-entry-addition-parameter-name'], '') -%}
 {% endif -%}
 
-{% set apache_port = next_port -%}
-{% set haproxy_port = next_port + 1 -%}
-{% set next_port = next_port + 2 -%}
+{% set apache_port = next_port() -%}
+{% set haproxy_port = next_port() -%}
 
 {% set apache_ip_list = [ipv4] -%}
 {% if ipv6_set -%}
@@ -184,13 +184,12 @@ ooo-uno-path = {{ parameter_dict['libreoffice-bin'] }}/basis-link/program
 {%   set name = 'cloudooo-' ~ index -%}
 [{{ cloudooo(name) }}]
 < = cloudooo-base
-port = {{ next_port }}
-openoffice-port = {{ next_port + 1 }}
+port = {{ next_port() }}
+openoffice-port = {{ next_port() }}
 configuration-file = ${directory:etc}/{{ name }}.cfg
 data-directory = ${directory:srv}/{{ name }}
 wrapper = ${directory:services}/{{ name }}
 
-{%   set next_port = next_port + 2 -%}
 {% endfor -%}
 
 [haproxy]
diff --git a/software/cloudooo/instance.cfg.in b/software/cloudooo/instance.cfg.in
index 82819bb03828bf124803d23746b0f22b63dff486..8c3e7547f21cb811a2e93b8dff478d3c8927cd65 100644
--- a/software/cloudooo/instance.cfg.in
+++ b/software/cloudooo/instance.cfg.in
@@ -39,6 +39,7 @@ extensions = jinja2.ext.do
 extra-context =
     section parameter_dict cloudooo-dynamic-template-parameter-dict
     key ipv4_set slap-parameters:ipv4
+    import itertools itertools
 
 [switch-softwaretype]
 recipe = slapos.cookbook:softwaretype
diff --git a/software/cloudooo/software-common.cfg b/software/cloudooo/software-common.cfg
index 5a76559a800cb77831cdce7999785fce7860c0a2..972a776bb3594ebc00325ec90b00743a925bcbaa 100644
--- a/software/cloudooo/software-common.cfg
+++ b/software/cloudooo/software-common.cfg
@@ -1,5 +1,6 @@
 [buildout]
 extends =
+  buildout.hash.cfg
   ../../stack/cloudooo.cfg
   ../../stack/logrotate/buildout.cfg
 parts =
@@ -25,8 +26,7 @@ cert = ${slap-connection:cert-file}
 recipe = slapos.recipe.template:jinja2
 # XXX: "template.cfg" is hardcoded in instanciation recipe
 rendered = ${buildout:directory}/template.cfg
-template = ${:_profile_base_location_}/instance.cfg.in
-md5sum = 4543e62c41726ef074454252c4951ac8
+template = ${:_profile_base_location_}/${:filename}
 mode = 640
 
 [template-cloudooo-base]
@@ -81,6 +81,5 @@ template-logrotate-base = ${template-logrotate-base:rendered}
 
 [template-cloudooo-instance]
 recipe = slapos.recipe.build:download
-url = ${:_profile_base_location_}/instance-cloudooo.cfg.in
-md5sum = 045830db85e1200f765788aa8b62289e
+url = ${:_profile_base_location_}/${:filename}
 mode = 640