General simplifications and bugfixes, just a work-in-progress