Fixed bugs with restriction checking