various adjustments, code organization