Some refactoring, some defect fixes, some new code