added a dependency
moved functions from another project; some reorganization and bugfixes
of end cases; made some function a little more efficient.