fix some error checking in optimizations to front end