Error message fix + minor code tweak