general bugfix & cleanup