Some more bugfixes and func