Support new schema, various bug fix