Refactorization and cleaning. Added test sequences