Correct schema handling, fixes #486 and #487