replace some assertions with calls to error()
add fixme