Fixed error message printing bugs