further refactoring
refactoring
minor
merge with clemos version