finished failure optimization changes, fixed several bugs introduced during changes