Some code changes, code reorganisation