Splitted program in modules. Tidied up some definitions.