Splitted into modules, added tests.