Bugfix, refactor