Bug fixes, modular design, manual mask specifying

The earlier implementation had a lot of bugs , plus had a single long
procedure. New implementation has a modular design and each module has
been tested thoroughly for correctness. The sample has an interface to
mark mask manually.