Bugfix/cleanup when