Major revision

Completely changed layout of the package, improved tests, made lua scripts more general.