minor refactoring + comments for erik.