Bugfix and codestructure