Reorganisation and rewrite

Better encapsulation of the code and organisation of the folder.