Modularity

Pull request to merge 'modularity' branch with master. 'modularity' contains changes that aim to modularize the project. I have split functional units into their own files. The files have use UMD and so it is possible to use regula with and without AMD.