commented code removed
glitch detection (using algorithm proposed by Bedrich)