Add anchor check and fix errors