first large cleanup and bugfix iteration of aprox 5