Working segmentation rules

Full implementation of segmentation rules. Working program.
Merge pull request #3 from denDAY04/Segmentation-rules

Working segmentation rules, fixes #1