Fix #813 and #814