better flood protection, some cleanup as well as bugfixes