Added a whole much of comments and tests. Have also reorganised the directory structure.