Added continuity checks, fixed bugs