Add errors. Fix some bugs