half-way completely refactored
merged