Another bugfix attempt and some tidying