Several code adjustments