bugfixing + codeclean up + refactoring
merge fix