merged 6.1.6 code with observer stuff, doesnt work too well