simplifications and bugfix