[UPDATE] fix numerous bugs