code simplification. minor fixes.